home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
lnklst10.zip
/
TESTLL.C
< prev
Wrap
C/C++ Source or Header
|
1993-01-19
|
1KB
|
77 lines
#include "linklist.h"
#include <string.h>
char *array[] =
{
"Banana",
"Apple",
"Orange",
"Grape",
"Cherry",
"Mango",
"Tomato"
};
NODEPTR head, ndp;
/*---------------------------------------------------------------------------*/
void disp_ll( void )
{
ndp = NodeFirst( head );
printf( "\n" );
for( ;; )
{
if( ndp == head )
break;
printf( "%s\n", (char *)ndp->data );
ndp = NodeNext( ndp );
}
printf( "\nPress a key:" );
getch();
printf( "\n\n" );
return;
}
/*---------------------------------------------------------------------------*/
void main( void )
{
int i;
char *ptr;
head = InitList();
ndp = head;
for( i = 0; i < 7; i++ )
{
ndp = NodeInsert( ndp, strlen( array[i] )+1 );
strcpy( (char *) ndp->data, array[i] );
}
disp_ll();
printf( "Deleting 3rd node..." );
ndp = NodeNumtoPtr( 2, head );
NodeDelete( ndp );
disp_ll();
printf( "Inserting a 3rd node using 5th node's data..." );
ndp = NodeNumtoPtr( 4, head );
ptr = ndp->data;
ndp = NodeInsert( NodeNumtoPtr( 1, head ), strlen( ptr ) + 1 );
strcpy( ndp->data, ptr );
disp_ll();
}